package com.seeyon.kk.utils;

import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;

import com.google.common.collect.Maps;

import jersey.repackaged.com.google.common.collect.Lists;

public class MapToLowerCaseUtils {

	/**
	 * Map<String, Object> 字段转小写
	 * @param orgMap
	 * @return
	 */
	public static Map<String, Object> mapToLower(Map<String, Object> orgMap){
		Map<String, Object> resultMap = new HashMap<>();
		if(orgMap == null || orgMap.isEmpty())
			return resultMap;
		Set<String> keySet = orgMap.keySet();
		for (String key : keySet) {
			resultMap.put(key.toLowerCase(), orgMap.get(key));
		}
		return resultMap;
	}
	
	/**
	 * List<Map<String, Object>>  字段转小写
	 * @param orgMap
	 * @return
	 */
	public static List<Map<String, Object>> listMapToLower(List<Map<String, Object>> orgMap){
		if(orgMap == null || orgMap.isEmpty())
			return orgMap;
		List<Map<String, Object>> list = Lists.newArrayList();
		for (Map<String, Object> map : orgMap) {
			Set<String> keySet = map.keySet();
			Map<String, Object> temp = Maps.newHashMap();
			for (String key : keySet) {
				temp.put(key.toLowerCase(), map.get(key));
			}
			list.add(temp);
		}
		return list;
	}
}
